/*
 * @LastEditors: whitechiina 1293616053@qq.com
 * @LastEditTime: 2023-03-16 14:27:35
 */
import React, { useEffect, useState } from 'react'

import {
  BrowserRouter as Router,
  Routes,
  Route,
  useLocation
} from "react-router-dom"

import { ConfigProvider } from 'zarm'
import NavBar from '@/components/NavBar'

import routes from '@/router'
function App() {
  const location = useLocation()
  const { pathname } = location
  const needNav = ['/', '/data', '/user']
  const [showNav, setShowNav] = useState(true) // 是否展示 Nav
  useEffect(() => {
    setShowNav(needNav.includes(pathname))
  }, [pathname]) 
  return <>
    <ConfigProvider primaryColor={'#007fff'}>
       <Routes>
        {routes.map(route => <Route exact key={route.path} path={route.path} element={<route.component />} />)}
       </Routes>
    </ConfigProvider>
    <NavBar showNav={showNav} />
  </>
}
export default App
